# coding=utf-8
# !/usr/bin/python3
import requests

from 解密 import official_price,sub_title

cookies = {
    'ttwid': '1%7C6_KYzEh9V-Bef8jXbq21xWKGvPo9TweMv9mlvRn66mE%7C1724512817%7C8d0a3cd505c48816c0a660282bd896ca8106fe8e8f5384a72873fdb1f5e8088d',
    'tt_webid': '7406726077219276350',
    'tt_web_version': 'new',
    'is_dev': 'false',
    'is_boe': 'false',
    'Hm_lvt_3e79ab9e4da287b5752d8048743b95e6': '1724512817',
    'HMACCOUNT': 'ED0735D1CE0FB96D',
    's_v_web_id': 'verify_m08aemjh_86A9BqYV_q5HQ_4hi9_8tSE_YeVRykpJVaK2',
    'city_name': '%E9%81%B5%E4%B9%89',
    '_gid': 'GA1.2.210096577.1724512825',
    'Hm_lpvt_3e79ab9e4da287b5752d8048743b95e6': '1724512911',
    '_ga': 'GA1.2.1580677000.1724512823',
    '_ga_YB3EWSDTGF': 'GS1.1.1724512822.1.1.1724512914.58.0.0',
}

headers = {
    'accept': '*/*',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    'content-type': 'application/x-www-form-urlencoded',
    # 'cookie': 'ttwid=1%7C6_KYzEh9V-Bef8jXbq21xWKGvPo9TweMv9mlvRn66mE%7C1724512817%7C8d0a3cd505c48816c0a660282bd896ca8106fe8e8f5384a72873fdb1f5e8088d; tt_webid=7406726077219276350; tt_web_version=new; is_dev=false; is_boe=false; Hm_lvt_3e79ab9e4da287b5752d8048743b95e6=1724512817; HMACCOUNT=ED0735D1CE0FB96D; s_v_web_id=verify_m08aemjh_86A9BqYV_q5HQ_4hi9_8tSE_YeVRykpJVaK2; city_name=%E9%81%B5%E4%B9%89; _gid=GA1.2.210096577.1724512825; Hm_lpvt_3e79ab9e4da287b5752d8048743b95e6=1724512911; _ga=GA1.2.1580677000.1724512823; _ga_YB3EWSDTGF=GS1.1.1724512822.1.1.1724512914.58.0.0',
    'origin': 'https://www.dongchedi.com',
    'pragma': 'no-cache',
    'priority': 'u=1, i',
    'referer': 'https://www.dongchedi.com/usedcar/x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-440100-1-x-x-x-x-x',
    'sec-ch-ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
    'x-forwarded-for': '',
}

params = {
    'aid': '1839',
    'app_name': 'auto_web_pc',
}

data = '&sh_city_name=遵义&page=1&limit=20'.encode()

response = requests.post(
    'https://www.dongchedi.com/motor/pc/sh/sh_sku_list',
    params=params,
    cookies=cookies,
    headers=headers,
    data=data,
).json()
product_info={}
for i in response['data']['search_sh_sku_info_list']:
    product_info = {
        # "official_price": i['official_price'],
        # "sh_price": i['sh_price'],
        # "sub_title": i['sub_title'],
        "title": i['title'],
        "official_price": official_price(i['official_price']),
        "sh_price": official_price(i['sh_price']),
        "sub_title": sub_title(i['sub_title']),
    }
    # 将该字典添加到列表中
    print(product_info)